﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;

namespace agile_tool.userControl
{
    /// <summary>
    /// Interaction logic for projectItem.xaml
    /// </summary>
    public partial class projectItem : UserControl
    {
        public int id;
        public projectItem()
        {
            InitializeComponent(); tbDesc.IsEnabled = false; tbName.IsEnabled = false; tbSprintDuration.IsEnabled = false;
            thisState = states.Closed;
        }
        public enum states {editOpen,viewOpen,Closed }
        public states thisState;

        public void openView()
        {
            Storyboard rtt = (Storyboard)Resources["openTheDesc"];
            rtt.Begin();
            thisState = states.viewOpen; 
        }

        public void closeTheDesc()
        {
            Storyboard rtt = (Storyboard)Resources["closeTheDesc"];
            rtt.Begin();
            tbDesc.IsEnabled = false;
            tbName.IsEnabled = false;
            tbSprintDuration.IsEnabled = false;
            thisState = states.Closed;
        }

        public void openTheDesc()
        {
            Storyboard rtt = (Storyboard)Resources["openTheDesc"];
            rtt.Begin();
            tbDesc.IsEnabled = true;
            tbName.IsEnabled = true;
            tbSprintDuration.IsEnabled = true;
            thisState = states.editOpen;
        }

        private void btnView_Click(object sender, RoutedEventArgs e)
        {
            if(thisState == states.Closed)
                 openView();
            else if (thisState == states.viewOpen)
                closeTheDesc();
            else
                MessageBox.Show("Save Changes First");
        }
        private void tbPriority_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                int.Parse(((TextBox)sender).Text);
            }
            catch { ((TextBox)sender).Text = "0"; }
        }

    }
}
